package org.yy;

import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.apache.commons.io.IOUtils;
import org.eclipse.swt.graphics.Image;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.LinkedHashMap;

public class DevTest {
    private static final String PROJECT_PATH = System.getProperty("user.dir");

    @Test
    public void test1() {
        String property = System.getProperty("user.dir");
        System.out.println(property);
    }

    @Test
    public void test2() throws Exception {
        String jsonString = "{   'id': 'cd0ab99e-9161-11ec-aa11-fe5bd620134b',   'businessKey': '1494959011309219842',   'businessTitle': '管理员申请请假1天',   'processDefId': 'Process_18tcg6s:2:d85de11e-8951-11ec-9f4f-c251f1f883b1',   'processDefName': '请假申请流程-V2',   'startTime': '2022-02-19 16:56:18',   'endTime': null,   'startTimeString': '2022-02-19 16:56',   'endTimeString': null,   'duration': null,   'startUserId': 'e9ca23d68d884d4ebb19d07889727dae',   'startUserName': '管理员',   'startDeptId': 'b1277d6810ff4fa3afa19b39162a43a9',   'startDeptName': '研发部',   'processInstanceId': 'cd0ab99e-9161-11ec-aa11-fe5bd620134b',   'processInstanceState': 'ACTIVE',   'myInstanceClassify': null,   'tenantId': null }";
        Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().create();
        JsonParser jp = new JsonParser();
        JsonElement je = jp.parse(jsonString);
        String format = gson.toJson(je);
        System.out.println(format);
    }

    @Test
    public void test3() {
        String jsonString = "{   'id': 'cd0ab99e-9161-11ec-aa11-fe5bd620134b',   'businessKey': '1494959011309219842',   'businessTitle': '管理员申请请假1天',   'processDefId': 'Process_18tcg6s:2:d85de11e-8951-11ec-9f4f-c251f1f883b1',   'processDefName': '请假申请流程-V2',   'startTime': '2022-02-19 16:56:18',   'endTime': null,   'startTimeString': '2022-02-19 16:56',   'endTimeString': null,   'duration': null,   'startUserId': 'e9ca23d68d884d4ebb19d07889727dae',   'startUserName': '管理员',   'startDeptId': 'b1277d6810ff4fa3afa19b39162a43a9',   'startDeptName': '研发部',   'processInstanceId': 'cd0ab99e-9161-11ec-aa11-fe5bd620134b',   'processInstanceState': 'ACTIVE',   'myInstanceClassify': null,   'tenantId': null }";
        //JSONObject jsonObject = JSONObject.parseObject(jsonString);
        LinkedHashMap<String, Object> jsonObject = JSON.parseObject(jsonString, LinkedHashMap.class, Feature.OrderedField);
        String pretty = JSONObject.toJSONString(jsonObject, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat);
        System.out.println(pretty);
    }

    @Test
    public void test4() throws Exception {
        FileOutputStream outputStream = new FileOutputStream("");
//        MatrixToImageWriter.writeToStream(matrix, format, outputStream);

        FileInputStream inputStream = new FileInputStream("");
        Image image = new Image(null, inputStream);

        IOUtils.copy(inputStream,outputStream);


    }


}
